package com.example.springboot.consumer;

import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.stereotype.Component;

/**
 * @Description: GoodsConsumer
 * @Author wenlinyu
 * @Date: 2020/12/17 16:08
 * @Version 1.0
 */
@Component
@EnableAsync
public class GoodsConsumer {

    private Logger logger = LoggerFactory.getLogger(this.getClass());

    /**
     * 监听消费
     * @param record
     */
    @KafkaListener(topics = "goods-topic")
    public void listen(ConsumerRecord<?,?> record) {
        logger.info("==================> consumer msg success, partition = {}, offset = {}, value = {} \n",
                record.partition(), record.offset(), record.value());
    }
}
